#!/usr/bin/env python3
"""
最终测试脚本
"""

import requests
import json

def test_final_fix():
    """最终测试"""
    print("=== 最终CORS测试 ===")
    
    # 测试后端服务是否运行
    try:
        response = requests.get('http://localhost:5000/', timeout=5)
        print(f"✅ 后端服务运行正常: {response.status_code}")
    except:
        print("❌ 后端服务未运行，请先启动后端")
        return
    
    # 测试报表接口
    endpoints = [
        '/api/reports/summary',
        '/api/reports/winning-analysis',
        '/api/reports/prediction-trends'
    ]
    
    for endpoint in endpoints:
        url = f'http://localhost:5000{endpoint}'
        print(f"\n测试 {endpoint}:")
        
        try:
            # 测试GET请求
            response = requests.get(url, timeout=5)
            print(f"  状态码: {response.status_code}")
            
            if response.status_code == 200:
                print("  ✅ 请求成功")
                try:
                    data = response.json()
                    print(f"  数据: {json.dumps(data, ensure_ascii=False, indent=2)}")
                except:
                    print(f"  响应: {response.text}")
            else:
                print(f"  ❌ 请求失败: {response.text}")
                
        except Exception as e:
            print(f"  ❌ 测试失败: {e}")

if __name__ == '__main__':
    test_final_fix() 